<template>
	<!-- 大客户项目报备查询--(合同备案登记，，买受人(乙方))弹窗专用 -->
	<div>
		<!-- 搜索 -->
		<!-- <commonFilter ref="commonFilter" :defaultProjectStatus="projectStatusReview" :type="'selectList'" @filterChange="changeHandle" @onCollapse="collapseHandle" /> -->
		<TopFilter
			ref="commonTopFilter"
			:list="topFilterInit"
			:cols="3"
			labelWidth="90"
			@filterChange="changeHandle"
			@onCollapse="collapseHandle"
		></TopFilter>

		<!-- table -->
		<FilterTable
			ref="table"
			:height="'250'"
			:columns="columns"
			:fetchapi="fetchApi"
			:params="fetchParams"
			:selectionType="selectType"
			:isSelectColumn="isSelectColumn"
			:datakey="'data'"
			columnsRef='customerManage_approvalManage_inquire_contractRegisterSelectList_01'
			:onColumnsChange="columns => this.columns = columns"
			:onRowSelectChange="selectChange"
		>
		</FilterTable>
		<div class="dialogBottmView">
			<el-button @click="closeDialog">取 消</el-button>
			<el-button @click="saveDialog" type="primary">{{submit}}</el-button>
		</div>
	</div>
</template>
<script>
	import { dictionary } from '@/utils/dictMixin';
	import { region } from '@/api/cms-common/region';//行政区域

	import * as apiType from '@/api/cms-api/customerManage/approvalManage/types';
	import { findAllList } from '@/api/cms-api/customerManage/approvalManage';

	export default {
		mixins: [dictionary,region],
		props:{
			submit: {
				type: String,
				default: '确定'
			},
			selectType:{
				type: String,
				default: 'multiple'
			},
			projectStatus:{
				type:[String,Number],
				required:false,
				//默认已审核
				default:()=> apiType.PROJECT_STATUS_CHIEF_INSPECTOR_REVIEW
			},
			projectFollowUpStatus:{
				type:[String,Number],
				required:false,
				//默认已成交
				default:()=> apiType.PROJECT_FOLLOW_UP_STATUS_COMPLETED_TRANSACTION
			}
		},
		data() {
			return {
				projectStatusReview:this.projectStatus,
				visibleDrawer: false,
				isSelectColumn: true,
				isExamine:false,
				infoId: '', //记录行id
				type: 'add', //add编辑 ，info详情
				topFilterInit: this.topFilterInitFun(),
				columns: this.creatHeader(),
				fetchApi:findAllList,
				fetchParams:{projectStatus:this.projectStatus,projectFollowUpStatus:this.projectFollowUpStatus,queryByDealerCode:apiType.QUERY_BY_DEALER_VALUE},
				dataSource:[]
			};
		},
		mounted() {
			// this.init();
			this.BaseTable = this.$refs.table.$refs.pageTable;
		},
		methods: {
			// init(){
			// 	this.$refs.commonTopFilter.SUBMIT_FORM();
			// },
			//搜索获取数据
			async changeHandle(val) {
				// let fetchParams = Object.assign({projectStatus:this.projectStatus,projectFollowUpStatus:this.projectFollowUpStatus},val);
				// this.dataSource = await findAllList(fetchParams);
				// this.dataSource.total = this.dataSource.data.length;//当前数量
				this.fetchParams = Object.assign({projectStatus:this.projectStatus,projectFollowUpStatus:this.projectFollowUpStatus},val);
			},
			//选中
			selectChange(rows) {
				this.selectedRows = rows;
			},
			//保存
			saveDialog() {
				if(this.selectedRows.length == 0){
					this.$notify.warning({title: '提示信息',message:'请选择任意一条数据！'});
					return;
				}
				this.$emit('close', { visible: false, data: this.selectedRows });
			},
			//取消操作
			closeDialog() {
				this.$emit('close', { visible: false});
			},
			collapseHandle() {
				this.$nextTick(() => {
					this.BaseTable.EXECUTE_RESET_HEIGHT();
				});
			},
			//搜索数据
			topFilterInitFun() {
				return [
					{ type: 'INPUT', label: '客户公司名称', fieldName: 'customerName', placeholder: '请输入', initialValue: '' },
					{ type: 'INPUT', label: '项目编号', fieldName: 'projectCodeVague', placeholder: '请输入', initialValue: ''},
					{ type: 'INPUT', label: '项目名称', fieldName: 'projectName', placeholder: '请输入', initialValue: '' },
				];
			},
			//table表头和数据源
			creatHeader() {
				return [
					{
						title: '序号',
						dataIndex: 'index',
						width: 80,
						sorter: true,
						render: props => {
							return <span>{props.row.index + 1}</span>;
						}
					},
					{ title: '客户公司名称', dataIndex: 'customerName', sorter: true },
					{ title: '项目名称', dataIndex: 'projectName', sorter: true },
					{
						title: '客户类型',
						dataIndex: 'customerType',
						sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.customerType, '2506')}</span>;
						}
					},
					{ title: '客户性质', dataIndex: 'customerProperty', sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.customerProperty, '2534')}</span>;
						}
					},
					{
						title: '项目跟进状态',
						dataIndex: 'projectFollowUpStatus',
						sorter: true,
						render: props => {
							return <span>{this.createDictText(props.row.projectFollowUpStatus, '2581')}</span>;
						}
					},
					{ title: '项目编号', dataIndex: 'projectCode', sorter: true },
				];
			},
		}
	};
</script>

<style lang="less" scoped>
</style>
